package com.infinit.selfhelp.common.utils

import android.os.SystemClock
import android.view.View

class DebouncedOnClickListener(
    private val debounceTime: Long = 600L,
    private val action: (View) -> Unit
) : View.OnClickListener {

    private var lastClickTime: Long = 0

    override fun onClick(v: View) {
        val currentTime = SystemClock.elapsedRealtime()
        if (currentTime - lastClickTime >= debounceTime) {
            lastClickTime = currentTime
            action(v)
        }
    }
}
